using System.Collections.Generic;
using System.Linq;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using HengTong.Model.Db.System;


namespace HengTong.ViewModel._Admin.SysSsoApplicationVms
{
    public partial class SysSsoApplicationListVm : BaseListVm<SysSsoApplicationView, SysSsoApplicationSearcher>
    {

        protected override IEnumerable<IGridColumn<SysSsoApplicationView>> InitGridHeader()
        {
            return new List<GridColumn<SysSsoApplicationView>>{
                this.MakeGridHeader(x => x.AppId),
                this.MakeGridHeader(x => x.AppName),
                this.MakeGridHeader(x => x.CallbackUrl),
                this.MakeGridHeader(x => x.IsActive),
                this.MakeGridHeader(x => x.Description),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysSsoApplicationView> GetSearchQuery()
        {
            var query = DC.Set<SysSsoApplication>()
                .CheckContain(Searcher.AppId, x=>x.AppId)
                .CheckContain(Searcher.AppName, x=>x.AppName)
                .CheckContain(Searcher.CallbackUrl, x=>x.CallbackUrl)
                .CheckEqual(Searcher.IsActive, x=>x.IsActive)
                .CheckContain(Searcher.Description, x=>x.Description)
                .Select(x => new SysSsoApplicationView
                {
				    ID = x.ID,
                    AppId = x.AppId,
                    AppName = x.AppName,
                    CallbackUrl = x.CallbackUrl,
                    IsActive = x.IsActive,
                    Description = x.Description,
                })
                .OrderBy(x => x.ID);
            return query;
        }
    }

    public class SysSsoApplicationView : SysSsoApplication{

    }
}
